package com.cuit.controller;

import com.cuit.dao.PatientDao;
import com.cuit.dao.impl.PatientDaoImpl;
import com.cuit.pojo.Patient;
import com.cuit.service.Impl.PatientServiceImpl;
import com.cuit.service.PatientService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class PersonalCenterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String p_name = req.getParameter("p_name");
        String p_id = req.getParameter("p_id");
        String id_card = req.getParameter("id_card");
        String p_age = req.getParameter("p_age");
        String p_sex = req.getParameter("p_sex");
        System.out.println(p_id);
        Patient patient = new Patient(p_name,p_id,id_card,p_age,p_sex);
        req.getSession().setAttribute("patient",patient);
        PatientService patientService = new PatientServiceImpl();
        patientService.modify(patient);
        System.out.println("修改成功！！！");
        resp.sendRedirect("patient/personal_center2.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
